//
//  MoreViewController.swift
//  Swift训练
//
//  Created by zhenjingxiong on 2018/8/30.
//  Copyright © 2018年 zhenjingxiong. All rights reserved.
//

import UIKit


class MoreViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource {
    
    

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(self.listView)
        self.listView.snp.makeConstraints { (make) in
            make.edges.equalTo(self.view)
        }
        
        self.listView.register(MoreFirstCell.self, forCellReuseIdentifier: "MoreFirst")
        self.listView.register(MoreSecondCell.self, forCellReuseIdentifier: "MoreSecond")
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 15
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.section == 0 {
            return 80
        }else{
            return 50
        }
    }
    
    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        view.tintColor = UIColor.withHex(hexString: "#eeeeee")
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        
        if indexPath.section == 0 {
            let cell = tableView.dequeueReusableCell(withIdentifier: "MoreFirst")
            return cell!
        }else{
            let cell:MoreSecondCell = tableView.dequeueReusableCell(withIdentifier: "MoreSecond") as! MoreSecondCell
            
            if indexPath.section == 1 {
               cell.leftLabel.text = "我的业绩"
               cell.leftImageView.image = UIImage.init(named: "icon_more_achievement")
            }else{
               cell.leftLabel.text = "关于我们"
                cell.leftImageView.image = UIImage.init(named: "icon_guanyu")
            }
            
            
            return cell
        }
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.section {
        case 0:
            let PC = PersonalInformationViewController()
            self.navigationController?.pushViewController(PC, animated: true)
        case 1:
            let MyPerformanceVC = MyPerformanceViewController()
            self.navigationController?.pushViewController(MyPerformanceVC, animated: true)
        default:
            print("wdd")
            let aboutUS = AboutUsViewController()
            self.navigationController?.pushViewController(aboutUS, animated: true)
            
        }
    }
    lazy var listView: UITableView = {
        let listView = UITableView.init()
        listView.delegate = self
        listView.dataSource = self
        listView.sectionFooterHeight = 0.01
        listView.sectionHeaderHeight = 0.01
        listView.backgroundColor = UIColor.white
        listView.tableFooterView = UIView.init()
        return listView
    }()
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
